﻿@using Classified.Data.Repositories
@using Classified.Service

@model IEnumerable<Classified.Domain.Entities.ClassifiedAd>
@{
    ViewBag.Title = ViewBag.UserName + "'s Ads";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var newmsg = MessageInfoRepositories.GetNewMessageByUserId(ViewBag.UserId);
}

<legend> My Ads > @ViewBag.UserName </legend>
@if (ViewBag.IsActive == false)
{
    <div class="alert alert-heading">
        <a href="@Url.Action("SelectPassword","Account")">Select a Password</a> to access My Ads directly in the future.
    </div>
}
<div class="span4 thumbnail">
    <fieldset> <legend>My Messages</legend>
   
    @if(newmsg == 0)
    {
        <a href="@Url.Action("Messages", "Home")">You have no new messages</a>
    }
    else
    {
        <a href="@Url.Action("Messages", "Home")">You have <b>@newmsg</b> new messages</a>
    }
         
     
     </fieldset>
    
</div>


<div class="span7 thumbnail">
    <legend>Settings</legend>
    <p>
        @Html.ActionLink("View my profile", "MyProfile", "Account")</p>
    <p>
        @Html.ActionLink("Edit my profile", "EditProfile", "Account")</p>
    <p>
        @Html.ActionLink("Change My Password", "ChangePassword", new { controller = "Account" })</p>
</div>
    <div class="clear">
    </div>

<div style="margin-bottom: 18px;" class="tabbable">
    <ul class="nav nav-tabs">
        <li class="active"><a data-toggle="tab" href="#active">Active Ads</a></li>
        <li class=""><a data-toggle="tab" href="#featured">Featured Ads</a></li>
        <li class=""><a data-toggle="tab" href="#removed">Removed Ads</a></li>
        <div class="clear">
        </div>
    </ul>
    <div style="padding-bottom: 9px;" class="tab-content">
        <div id="active" class="tab-pane active">
            <table class="table">
                @foreach (var item in Model.Where(x => x.IsActive && x.IsEnhanced == false))
                {
                    <tr>
                        <td width="1%" class="table-img">
                            <div class="thumbnail">
                                @if (item.ClassifiedPicture.Count == 0)
                                {
                                    <img src="/Images/120/90/images/no-image.jpg" width="120" height="90" alt="@item.Title"
                                     title="@item.Title" align="left"/>
                                }
                                else
                                {
                                    <img src="/Images/120/90//classified/@item.ClassifiedPicture.FirstOrDefault().ImageGuid" width="120" height="90" alt="@item.Title"
                                     title="@item.Title" align="left"/>
                                }
                            </div>
                        </td>
                        <td width="50%">
                            <p>
                                <h4>@Html.DisplayFor(modelItem => item.Title)</h4>
                            </p>
                            <p>
                                <label>
                                    Location :</label>
                                @{
                                int i = 0;
                                }
                                @foreach (var l in item.Locations)
                                {

                                    if (i > 0)
                                    {
                                    <text>,</text>
                                    }
                                    i++;
                                    @Html.DisplayFor(modelItem => l.Name)
                                }</p>
                            <p>
                                <label>
                                    Address :</label>@Html.DisplayFor(modelItem => item.Address)</p>
                            <p>
                                <label>
                                    Posted Date :</label>@item.CreatedOnUtc.ToLongDateString()&nbsp; @item.CreatedOnUtc.ToLongTimeString()
                            </p>
                            <p>
                                <label>
                                    Comment(@item.ClassifiedComments.Count())</label></p>
                        </td>
                        <td width="10%">
                            <a href="@Url.Action("Edit", "ClassifiedAds", new { id = item.Id })" class="btn btn-success">
                                <i class=" icon-edit icon-white"></i>&nbsp;Edit</a><br />
                            <br />
                            @* <a href="@Url.Action("publish", "Home")" class="btn btn-primary">
                                <i class="icon-briefcase icon-white"></i>&nbsp;Publish this Ads</a><br /><br />*@
                            <a href="@Url.Action("Delete", "ClassifiedAds", new { id = item.Id })" class="btn btn-danger" onclick="return confirm('Are you sure you wish to delete this Classified?');">
                                <i class="icon-trash icon-white"></i>Delete</a>
                        </td>
                    </tr>
                    
                }
            </table>
        </div>
        <div id="featured" class="tab-pane">
            <table class="table">
                @foreach (var item in Model.Where(x => x.IsEnhanced))
                {
                   
                    <tr>
                        <td class=" table-img " width="1%">
                            <div class="list-item-pic thumbnail">
                                @if (item.ClassifiedPicture.Count == 0)
                                {
                                    <img src="/Images/120/90/images/no-image.jpg" width="120" height="90" alt="@item.Title"
                                     title="@item.Title" align="left"/>
                                }
                                else
                                {
                                    <img src="/Images/120/90/classified/@item.ClassifiedPicture.FirstOrDefault().ImageGuid" width="120" height="90" alt="@item.Title"
                                     title="@item.Title" align="left"/>
                                }
                                <span class="paid-customer">&nbsp;</span>
                            </div>
                        </td>
                        <td width="50%">
                            <p>
                                <h4>@Html.DisplayFor(modelItem => item.Title)</h4>
                            </p>
                            <p>
                                <label>
                                    Location :</label>
                                @{
                                int i = 0;
                                }
                                @foreach (var l in item.Locations)
                                {

                                    if (i > 0)
                                    {
                                    <text>,</text>
                                    }
                                    i++;
                                    @Html.DisplayFor(modelItem => l.Name)
                                }</p>
                            <p>
                                <label>
                                    Address :</label>@Html.DisplayFor(modelItem => item.Address)</p>
                            <p>
                                <label>
                                    Posted Date :</label>@item.CreatedOnUtc.ToLongDateString()&nbsp; @item.CreatedOnUtc.ToLongTimeString()
                            </p>
                            <p>
                                <label>
                                    Comment(@item.ClassifiedComments.Count())</label></p>
                        </td>
                        <td width="10%">
                            <a href="@Url.Action("Edit", "ClassifiedAds", new { id = item.Id })" class="btn btn-success">
                                <i class=" icon-edit icon-white"></i>&nbsp;Edit</a><br />
                            <br />
                            <a href="@Url.Action("Delete", "ClassifiedAds", new { id = item.Id })" class="btn btn-danger" onclick="return confirm('Are you sure you wish to delete this Classified?');">
                                <i class="icon-trash icon-white"></i>Delete</a>
                        </td>
                    </tr>
                    
                }
            </table>
        </div>
        <div id="removed" class="tab-pane">
            <table class="table">
                @foreach (var item in Model.Where(x => x.Deleted))
                {
                    
                    <tr>
                        <td width="1%" class="table-img">
                            <div class="thumbnail">
                                @if (item.ClassifiedPicture.Count == 0)
                                {
                                    <img src="/Images/120/90/images/no-image.jpg" width="120" height="90" alt="@item.Title"
                                     title="@item.Title" align="left"/>
                                }
                                else
                                {
                                    <img src="/Images/120/90//classified/@item.ClassifiedPicture.FirstOrDefault().ImageGuid" width="120" height="90" alt="@item.Title"
                                     title="@item.Title" align="left"/>
                                }
                                <span>&nbsp;</span>
                            </div>
                        </td>
                        <td width="50%">
                            <p>
                                <h4>@Html.DisplayFor(modelItem => item.Title)</h4>
                            </p>
                            <p>
                                <label>
                                    Location :</label>
                                @{
                                int i = 0;
                                }
                                @foreach (var l in item.Locations)
                                {

                                    if (i > 0)
                                    {
                                    <text>,</text>
                                    }
                                    i++;
                                    @Html.DisplayFor(modelItem => l.Name)
                                }</p>
                            <p>
                                <label>
                                    Address :</label>@Html.DisplayFor(modelItem => item.Address)</p>
                            <p>
                                <label>
                                    Posted Date :</label>@item.CreatedOnUtc.ToLongDateString()&nbsp; @item.CreatedOnUtc.ToLongTimeString()
                            </p>
                            <p>
                                <label>
                                    Comment(@item.ClassifiedComments.Count())</label></p>
                        </td>
                        <td width="10%">
                            <a href="@Url.Action("Edit", "ClassifiedAds", new { id = item.Id })" class="btn btn-success">
                                <i class=" icon-edit icon-white"></i>&nbsp;Edit</a><br />
                            <br />
                            <a href="@Url.Action("Delete", "ClassifiedAds", new { id = item.Id })" class="btn btn-danger" onclick="return confirm('Are you sure you wish to delete this Classified?');">
                                <i class="icon-trash icon-white"></i>Delete</a>
                        </td>
                    </tr>
                    
                }
            </table>
        </div>
    </div>
</div>
